﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Collections.TreeCollections;
using System.Xml.Linq;

namespace FeatureModelTool.ProjectView.ProjectTreeStructures
{
    public class ProjectTreeRoot : TreeRoot
    {
        public override string Name
        {
            get
            {
                return ((ProjectTree)this.TreeOwner).ProjectName;
            }
        }
        public string FullPath { get { return ((ProjectTree)this.TreeOwner).ProjectRootPath; } }


        public ProjectTreeRoot(TreeNodeIdentify id) : base(id)
        {
            
        }
        /// <summary>
        /// Constain File
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public bool ContainFile(string fileName)
        {
            foreach (INonRoot nonRoot in this.Children)
            {
                ProjectFile file = nonRoot as ProjectFile;
                if (file == null)
                {
                    continue;
                }
                if (fileName == file.Name)
                {
                    return true;
                }
            }
            return false;
        }

        /// <summary>
        /// args[0]: string folderName
        /// </summary>
        /// <param name="id"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public static TreeObject ConstructRoot(TreeNodeIdentify id, object[] args)
        {
            return new ProjectTreeRoot(id);
        }

        #region XML Parser
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override XElement ToXElem()
        {
            XElement xelem = base.ToXElem();
            return xelem;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="xelem"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        internal static void xmlParser(XElement xelem, TreeObject obj)
        {
        }
        #endregion

        public override object Clone()
        {
            throw new NotImplementedException();
        }
    }
}
